package andriod.action.doc;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import andriod.service.ArdDocService;
import andriod.service.ArdInfoService;
import andriod.util.DocumentTypeProcessor;

import com.jcrj.action.BaseAction;
import com.jcrj.common.Constants;
import com.jcrj.entity.ODocDown;
import com.jcrj.entity.ODocument;
import com.jcrj.entity.ONode;
import com.jcrj.entity.OProcessHis;
import com.jcrj.entity.OProcessinstance;
import com.jcrj.entity.OTypeSet;
import com.jcrj.entity.OUser;
import com.jcrj.entity.Subject;
import com.jcrj.service.DocumentFlowService;
import com.jcrj.service.FileService;
import com.jcrj.service.SysLogService;
import com.jcrj.service.WorkflowManagerService;
import com.jcrj.util.DateProcessor;
import com.jcrj.util.GetText;

public class ArdDocAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	private SysLogService sysLogService;
	private WorkflowManagerService workflowManagerService;
	private ArdDocService ardDocService;
	private ArdInfoService ardInfoService;
	private DocumentFlowService documentFlowService;
	private FileService fileService;
	private ODocument document;
	private String propertyIds;
	private String nbyj;
	private String ldps;
	
	private String blqk;
	private String dcdb;
	private String docId;
	private int nodeId;
	private String message;
	private String supervisionTag;
	private String executors;
	private String status;
	private String flowId;
	private String[] userIds;
	private String contentId;
	public String addSubjectOut() {
		OUser ou = (OUser) super.getSession().get("userInfo");
		List<Subject> subjectList = this.workflowManagerService.getDispatcherList(ou.getOrgId().intValue());
		
		JSONArray jsonArray = JSONArray.fromObject(subjectList);
		getResponse().setContentType("text/json;charset=utf-8");
		PrintWriter writer;
		try {
			writer = getResponse().getWriter();
			writer.print(jsonArray.toString());
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
		return null;
	}

	public String docHome() {
		try {
			JSONObject obj = new JSONObject();
			OUser user = (OUser) super.getSession().get("userInfo");
			List<Integer> agents = this.sysLogService.getFlowAgentUser(user);
			String processId = this.workflowManagerService
					.getProcessinstanceList(user.getId().intValue(), agents);
			long count = this.ardDocService.countDoc(processId, "2");
			obj.put("todoInCount", Long.valueOf(count));
			processId = this.workflowManagerService
					.getDoneProcessinstanceList(user.getId().intValue());
			count = this.ardDocService.countDoc(processId, "2");
			obj.put("doneInCount", Long.valueOf(count));
			agents = this.sysLogService.getFlowAgentUser(user);
			processId = this.workflowManagerService.getProcessinstanceList(user
					.getId().intValue(), agents);
			count = this.ardDocService.countDoc(processId, "1");
			obj.put("todoOutCount", Long.valueOf(count));
			processId = this.workflowManagerService
					.getDoneProcessinstanceList(user.getId().intValue());
			count = this.ardDocService.countDoc(processId, "1");
			obj.put("doneOutCount", Long.valueOf(count));
			super.getResponse().getWriter().write(obj.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getTodoDocInList() {
		try {
			OUser user = (OUser) getSession().get("userInfo");
			List agents = this.sysLogService.getFlowAgentUser(user);
			String process = this.workflowManagerService
					.getProcessinstanceList(user.getId().intValue(), agents);
			long totalCount = this.documentFlowService.countMyDocument(process,
					"2", super.getTitle(), super.getStartDate(),
					super.getEndDate(), super.getFwzh()).longValue();
			long pageCount = ((totalCount - 1L) / 10L + 1L);
			List todoList = this.documentFlowService.getDocumentList(process,
					super.getCurrentPage(), "2", super.getTitle(),
					super.getStartDate(), super.getEndDate(), super.getFwzh());

			JsonConfig config = new JsonConfig();
			config.registerJsonValueProcessor(Date.class, new DateProcessor());
			config.registerJsonValueProcessor(java.util.Date.class,
					new DateProcessor());
			JSONArray array = JSONArray.fromObject(todoList, config);
			JSONObject obj = new JSONObject();
			obj.put("totalCount", totalCount);
			obj.put("pageCount", pageCount);
			obj.put("currentPage", super.getCurrentPage());
			obj.put("list", array);
			HttpServletResponse response = super.getResponse();
			response.setContentType("text/json;charset=utf-8");
			PrintWriter out = super.getResponse().getWriter();
			out.print(obj.toString());
			out.flush();

		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getDoneDocInList() {
		try {
			// OUser user = (OUser) super.getSession().get("userInfo");
			// String processId =
			// this.workflowManagerService.getDoneProcessinstanceList(user.getId().intValue());
			// List<ODocument> list = this.ardDocService.getDocList(processId,
			// "2");
			// JsonConfig config = new JsonConfig();
			// config.registerJsonValueProcessor(Date.class, new
			// DateProcessor());
			// JSONArray obj = JSONArray.fromObject(list, config);
			// super.getResponse().setCharacterEncoding("UTF-8");
			// super.getResponse().getWriter().write(obj.toString());
			// super.getResponse().getWriter().flush();

			OUser user = (OUser) getSession().get("userInfo");
			String process = this.workflowManagerService
					.getDoneProcessinstanceList(user.getId().intValue());
			long totalCount = this.documentFlowService.countMyDocument(process,
					"2", super.getTitle(), super.getStartDate(),
					super.getEndDate(), super.getFwzh()).longValue();
			long pageCount = ((totalCount - 1L) / 10L + 1L);
			List docList = this.documentFlowService.getDocumentList(process,
					super.getCurrentPage(), "2", super.getTitle(),
					super.getStartDate(), super.getEndDate(), super.getFwzh());

			JsonConfig config = new JsonConfig();
			config.registerJsonValueProcessor(Date.class, new DateProcessor());
			config.registerJsonValueProcessor(java.util.Date.class,
					new DateProcessor());
			JSONArray array = JSONArray.fromObject(docList, config);
			JSONObject obj = new JSONObject();
			obj.put("totalCount", totalCount);
			obj.put("currentPage", super.getCurrentPage());
			obj.put("pageCount", pageCount);
			obj.put("list", array);
			HttpServletResponse response = super.getResponse();
			response.setContentType("text/json;charset=utf-8");
			PrintWriter out = super.getResponse().getWriter();
			out.print(obj.toString());
			out.flush();

		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getTodoDocOutList() {
		try {

			OUser user = (OUser) getSession().get("userInfo");
			List agents = this.sysLogService.getFlowAgentUser(user);
			String process = this.workflowManagerService
					.getProcessinstanceList(user.getId().intValue(), agents);
			long totalCount = this.documentFlowService.countMyDocument(process,
					"1", super.getTitle(), super.getStartDate(),
					super.getEndDate(), super.getFwzh()).longValue();
			long pageCount = ((totalCount - 1L) / 10L + 1L);
			List docList = this.documentFlowService.getDocumentList(process,
					super.getCurrentPage(), "1", super.getTitle(),
					super.getStartDate(), super.getEndDate(), super.getFwzh());

			JsonConfig config = new JsonConfig();
			config.registerJsonValueProcessor(Date.class, new DateProcessor());
			config.registerJsonValueProcessor(java.util.Date.class,
					new DateProcessor());
			JSONArray array = JSONArray.fromObject(docList, config);
			JSONObject obj = new JSONObject();
			obj.put("totalCount", totalCount);
			obj.put("pageCount", pageCount);
			obj.put("currentPage", super.getCurrentPage());
			obj.put("list", array);
			HttpServletResponse response = super.getResponse();
			response.setContentType("text/json;charset=utf-8");
			PrintWriter out = super.getResponse().getWriter();
			out.print(obj.toString());
			out.flush();

		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getDoneDocOutList() {
		try {
			OUser user = (OUser) getSession().get("userInfo");
			String process = this.workflowManagerService
					.getDoneProcessinstanceList(user.getId().intValue());
			long totalCount = this.documentFlowService.countMyDocument(process,
					"1", super.getTitle(), super.getStartDate(),
					super.getEndDate(), super.getFwzh()).longValue();
			long pageCount = ((totalCount - 1L) / 10L + 1L);
			List docList = this.documentFlowService.getDocumentList(process,
					super.getCurrentPage(), "1", super.getTitle(),
					super.getStartDate(), super.getEndDate(), super.getFwzh());

			JsonConfig config = new JsonConfig();
			config.registerJsonValueProcessor(Date.class, new DateProcessor());
			config.registerJsonValueProcessor(java.util.Date.class,
					new DateProcessor());
			JSONArray array = JSONArray.fromObject(docList, config);
			JSONObject obj = new JSONObject();
			obj.put("totalCount", totalCount);
			obj.put("pageCount", pageCount);
			obj.put("currentPage", super.getCurrentPage());

			obj.put("list", array);
			HttpServletResponse response = super.getResponse();
			response.setContentType("text/json;charset=utf-8");
			PrintWriter out = super.getResponse().getWriter();
			out.print(obj.toString());
			out.flush();

		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getTaskDoc() {
		try {
			JsonConfig config = new JsonConfig();
			config.registerJsonValueProcessor(Date.class, new DateProcessor());
			Map obj = new HashMap();
			OUser user = (OUser) super.getSession().get("userInfo");
			ODocument document = this.documentFlowService
					.getDocumentById(Integer.parseInt(this.docId));
			obj.put("document", document);
			OProcessinstance processinstance = this.workflowManagerService
					.getProcessinstance(document.getProcessId().intValue());
			obj.put("processinstance", processinstance);
			List nodeList = this.workflowManagerService
					.getNextNode(processinstance.getNodeId().intValue());
			obj.put("nodeList", nodeList);
			List proportyList = this.workflowManagerService
					.getWriteFormProportyIdsByNode(processinstance.getNodeId()
							.intValue());
			String propertyIds = this.workflowManagerService
					.getFormProportyPageNames(proportyList);
			obj.put("propertyIds", propertyIds);
			ONode flowNode = this.workflowManagerService
					.getFlowNode(processinstance.getNodeId().intValue());
			obj.put("flowNode", flowNode);
			List backNodeList = this.workflowManagerService.getBackNodeList(
					processinstance.getId().intValue(), processinstance
							.getNodeId().intValue());
			obj.put("backNodeList", backNodeList);
			if (document.getSfstatus().equals("2")) {
				List departments = this.workflowManagerService.getDepartments(user.getOrgId().intValue());
				JsonConfig jsonConfig = new JsonConfig();
				jsonConfig.registerJsonValueProcessor(OTypeSet.class, new DocumentTypeProcessor());
				JSONArray array = JSONArray.fromObject(departments,jsonConfig);
				obj.put("departments", array);
			} else {
				List topList = this.documentFlowService.getDispatcherList(user
						.getOrgId().intValue());
				obj.put("topList", topList);
			}
			List fileList = this.fileService.getFileList(document
					.getFileArray());
			obj.put("fileList", fileList);
			JSONObject json = JSONObject.fromObject(obj, config);
			System.out.println(json.toString());
			super.getResponse().setCharacterEncoding("UTF-8");
			super.getResponse().getWriter().write(json.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getDoneTaskDoc() {
		try {
			Map<String, Object> obj = new HashMap<String, Object>();
			OUser user = (OUser) super.getSession().get("userInfo");
			ODocument document = this.documentFlowService
					.getDocumentById(Integer.parseInt(this.docId));
			obj.put("document", document);
			String id = super.getRequest().getParameter("id");
			if ((id != null) && (!"".equals(id))) {
				ODocDown doc = this.documentFlowService.getDocDownById(Integer.parseInt(id));
				doc.setIsRead("1");
				this.documentFlowService.updateDocDown(doc);
			}
			if (document.getSfstatus().equals("2")) {
				List departments = this.workflowManagerService
						.getDepartments(user.getOrgId().intValue());
				JsonConfig config = new JsonConfig();
				config.registerJsonValueProcessor(OTypeSet.class, new DocumentTypeProcessor());
				obj.put("departments", JSONArray.fromObject(departments, config));
				
				// downList
				List downList = this.documentFlowService.findDocDownListByDoc(document.getId().intValue());
				obj.put("downList", downList);
			} else {
				List topList = this.documentFlowService.getDispatcherList(user
						.getOrgId().intValue());
				obj.put("topList", topList);
			}
			List fileList = this.fileService.getFileList(document
					.getFileArray());
			obj.put("fileList", fileList);
			JsonConfig config = new JsonConfig();
			config.registerJsonValueProcessor(Date.class, new DateProcessor());
			JSONObject object = JSONObject.fromObject(obj, config);
			super.getResponse().setCharacterEncoding("UTF-8");
			super.getResponse().getWriter().write(object.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String passDoc() {
		try {
			OUser user = (OUser) getSession().get("userInfo");
			ODocument doc = this.documentFlowService
					.getDocumentById(this.document.getId().intValue());
			doc.setType(this.document.getType());
			doc.setPostFont1(this.document.getPostFont1());
			doc.setPostFont2(this.document.getPostFont2());
			doc.setPostFont3(this.document.getPostFont3());
			doc.setDraftOrg(this.document.getDraftOrg());
			doc.setArticleNumber(this.document.getArticleNumber());
			doc.setBeizhu(this.document.getBeizhu());
			doc.setCreateTime(this.document.getCreateTime());
			doc.setTitle(this.document.getTitle());
			doc.setTop(this.document.getTop());
			doc.setMjStatu(this.document.getMjStatu());
			doc.setHjStatu(this.document.getHjStatu());
			doc.setPrint(this.document.getPrint());
			doc.setPrintTime(this.document.getPrintTime());
			doc.setFjbs(this.document.getFjbs());
			doc.setFileArray(this.document.getFileArray());
			doc.setTextId(this.document.getTextId());
			doc.setWriteFrom(this.document.getWriteFrom());
			doc.setSendFrom(this.document.getSendFrom());
			doc.setThem(this.document.getThem());
			doc.setContentId(this.document.getContentId());
			if ((this.propertyIds != null) && (!"".equals(this.propertyIds))) {
				if (this.propertyIds.contains("nbyj")) {
					doc.setNbyj(Constants.isEmpety(doc.getNbyj())
							+ GetText.getFwHtmlText(this.document.getNbyj(),
									user.getName()));
				}
				
				if (this.propertyIds.contains("ldps")) {
					doc.setLdps(Constants.isEmpety(doc.getLdps())
							+ GetText.getFwHtmlText(this.document.getLdps(),
									user.getName()));
				}
				if (this.propertyIds.contains("dcdb")) {
					doc.setDcdb(Constants.isEmpety(doc.getDcdb())
							+ GetText.getFwHtmlText(this.document.getDcdb(),
									user.getName()));
				}
				if (this.propertyIds.contains("blqk")) {
					doc.setBlqk(Constants.isEmpety(doc.getBlqk())
							+ GetText.getFwHtmlText(this.document.getBlqk(),
									user.getName()));
				}

				if (this.propertyIds.contains("cbdwyj")) {
					doc.setOrgSugesstion(Constants.isTextEmpety(doc
							.getOrgSugesstion())
							+ GetText.getFwHtmlText(
									this.document.getOrgSugesstion(),
									user.getName()));
				}
				if (this.propertyIds.contains("hq")) {
					doc.setCounterSign(Constants.isTextEmpety(doc
							.getCounterSign())
							+ GetText.getFwHtmlText(
									this.document.getCounterSign(),
									user.getName()));
				}
				if (this.propertyIds.contains("hg")) {
					doc.setCheckDraft(Constants.isTextEmpety(doc
							.getCheckDraft())
							+ GetText.getFwHtmlText(
									this.document.getCheckDraft(),
									user.getName()));
				}
				if (this.propertyIds.contains("shyj")) {
					doc.setShyj(Constants.isTextEmpety(doc.getShyj())
							+ GetText.getFwHtmlText(this.document.getShyj(),
									user.getName()));
				}
				if (this.propertyIds.contains("syyj")) {
					doc.setSyyj(Constants.isTextEmpety(doc.getSyyj())
							+ GetText.getFwHtmlText(this.document.getSyyj(),
									user.getName()));
				}
				if (this.propertyIds.contains("qf")) {
					doc.setSignOff(Constants.isTextEmpety(doc.getSignOff())
							+ GetText.getFwHtmlText(this.document.getSignOff(),
									user.getName()));
				}
			}
			if ((this.supervisionTag != null)
					&& (!"".equals(this.supervisionTag)))
				doc.setSupervision("由" + user.getName() + "督办");
			else {
				doc.setSupervision("无人督办");
			}
			this.documentFlowService.saveTransitionDocument(doc, doc
					.getFlowId().intValue(), this.nodeId, this.executors, user,
					this.message);
			this.sysLogService.saveLog("公文管理", user.getName(), "提交了"
					+ this.document.getTitle() + "的公文");
			JSONObject obj = new JSONObject();
			obj.put("flag", Boolean.valueOf(true));
			super.getResponse().getWriter().write(obj.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String rejectDocment() {
		try {
			OUser user = (OUser) super.getSession().get("userInfo");
			ODocument doc = this.documentFlowService.getDocumentById(Integer
					.parseInt(this.docId));
			this.documentFlowService.updateRejectDocument(doc, this.status,
					user, this.message);
			this.sysLogService.saveLog("公文管理", user.getName(),
					"驳回了" + doc.getTitle() + "的公文");
			JSONObject obj = new JSONObject();
			obj.put("flag", Boolean.valueOf(true));
			super.getResponse().getWriter().write(obj.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String flowLook() {
		try {
			List<OProcessHis> processList = this.workflowManagerService
					.getProcessList(Integer.parseInt(this.flowId));
			for (OProcessHis his : processList) {
				if ("开始".equals(his.getStatus())) {
					his.setNodeName(his.getStatus());
				} else if ("退回".equals(his.getStatus())) {
					his.setNodeName("<font color='red'>" + his.getStatus()
							+ "</font>");
				} else {
					String nodeName = this.workflowManagerService
							.getNodeName(his.getStartNode());
					his.setNodeName(nodeName);
				}

				his.setUserName(this.workflowManagerService.getUserName(his
						.getActors()));
				his.setEndNodeName(this.workflowManagerService.getNodeName(his
						.getEndNode()));
			}
			OProcessinstance instance = this.workflowManagerService
					.getProcessinstance(Integer.parseInt(this.flowId));
			if ((instance != null) && ("task".equals(instance.getNodeStatus()))) {
				OProcessHis current = new OProcessHis();
				current.setNodeName(this.workflowManagerService
						.getNodeName(instance.getNodeId())
						+ "<br><font color='red'>(未处理)</font>");
				current.setExecutor(this.workflowManagerService
						.getUserName(instance.getExecutor()));
				current.setStatus("未处理");
				processList.add(current);
			}
			JsonConfig config = new JsonConfig();
			config.registerJsonValueProcessor(Date.class, new DateProcessor());
			JSONArray obj = JSONArray.fromObject(processList, config);
			super.getResponse().setCharacterEncoding("UTF-8");
			super.getResponse().getWriter().write(obj.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getCandidate() {
		try {
			List actorList = this.workflowManagerService
					.getExecutorList(this.nodeId);
			List list = this.workflowManagerService.getUserList(actorList);
			JSONObject obj = new JSONObject();
			obj.put("list", list);
			super.getResponse().setCharacterEncoding("UTF-8");
			super.getResponse().getWriter().write(obj.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String getOrgExecutor() {
		try {
			String orgIds = this.ardDocService
					.getOrgExecutorOrgIds(this.nodeId);
			List orgList = this.ardDocService.getOrgExecutorOrgList(orgIds);
			List userList = this.ardDocService.getOrgExecutorUserList(orgIds);
			JSONObject obj = new JSONObject();
			obj.put("list", orgList);

			super.getResponse().setCharacterEncoding("UTF-8");
			super.getResponse().getWriter().write(obj.toString());
			super.getResponse().getWriter().flush();
		} catch (IOException e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	
	public String saveDocDown() {
		List<String> useridsList = new ArrayList<String>();
		for(int i = 0;i<userIds.length;i++){
			String userid = userIds[i];
			String[] us = userid.split(",");
			for(int f = 0;f<us.length;f++){
				if(!"".equals(us[f].trim())){
					useridsList.add(us[f].trim());
				}
			}
		}
		String[] useridsArray = new String[useridsList.size()];
		for(int i=0;i<useridsArray.length;i++){
			useridsArray[i]=useridsList.get(i);
		}
		try {
			this.documentFlowService.saveDocDown(useridsArray, Integer.parseInt(this.docId), this.status);
			getResponse().getWriter().write("{\"flag\":true}");
			getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public String wordChange() {
		try {
			if (this.document != null) {
				if ((this.document.getTop() != null)
						&& (!"".equals(this.document.getTop()))) {
					this.document.setTop(URLDecoder.decode(
							URLDecoder.decode(this.document.getTop(), "UTF-8"),
							"UTF-8").trim());
				}
				if ((this.document.getPostFont1() != null)
						&& (!"".equals(this.document.getPostFont1()))) {
					this.document.setPostFont1(URLDecoder.decode(
							URLDecoder.decode(this.document.getPostFont1(),
									"UTF-8"), "UTF-8").trim());
				}
				if ((this.document.getPostFont2() != null)
						&& (!"".equals(this.document.getPostFont2()))) {
					this.document.setPostFont2(URLDecoder.decode(
							URLDecoder.decode(this.document.getPostFont2(),
									"UTF-8"), "UTF-8").trim());
				}
				if ((this.document.getThem() != null)
						&& (!"".equals(this.document.getThem()))) {
					this.document.setThem(URLDecoder
							.decode(URLDecoder.decode(this.document.getThem(),
									"UTF-8"), "UTF-8").trim());
				}
				if ((this.document.getWriteFrom() != null)
						&& (!"".equals(this.document.getWriteFrom()))) {
					this.document.setWriteFrom(URLDecoder.decode(
							URLDecoder.decode(this.document.getWriteFrom(),
									"UTF-8"), "UTF-8").trim());
				}
				if ((this.document.getTitle() != null)
						&& (!"".equals(this.document.getTitle()))) {
					this.document.setTitle(URLDecoder
							.decode(URLDecoder.decode(this.document.getTitle(),
									"UTF-8"), "UTF-8").trim()
							.replaceAll("\n", ""));
				}
				if ((this.document.getSendFrom() != null)
						&& (!"".equals(this.document.getSendFrom()))) {
					this.document.setSendFrom(URLDecoder.decode(
							URLDecoder.decode(this.document.getSendFrom(),
									"UTF-8"), "UTF-8").trim());
				}
			}
			JSONObject obj = new JSONObject();
			obj.put("content",
					this.ardInfoService.getBLOBString(this.contentId));
			obj.put("document", this.document);
			super.getResponse().setCharacterEncoding("UTF-8");
			super.getResponse().getWriter().write(obj.toString());
			super.getResponse().getWriter().flush();
		} catch (Exception e) {
			e.printStackTrace();
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} finally {
			try {
				super.getResponse().getWriter().close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public SysLogService getSysLogService() {
		return this.sysLogService;
	}

	public void setSysLogService(SysLogService sysLogService) {
		this.sysLogService = sysLogService;
	}

	public WorkflowManagerService getWorkflowManagerService() {
		return this.workflowManagerService;
	}

	public void setWorkflowManagerService(
			WorkflowManagerService workflowManagerService) {
		this.workflowManagerService = workflowManagerService;
	}

	public ArdDocService getArdDocService() {
		return this.ardDocService;
	}

	public void setArdDocService(ArdDocService ardDocService) {
		this.ardDocService = ardDocService;
	}

	public ArdInfoService getArdInfoService() {
		return this.ardInfoService;
	}

	public void setArdInfoService(ArdInfoService ardInfoService) {
		this.ardInfoService = ardInfoService;
	}

	public DocumentFlowService getDocumentFlowService() {
		return this.documentFlowService;
	}

	public void setDocumentFlowService(DocumentFlowService documentFlowService) {
		this.documentFlowService = documentFlowService;
	}

	public FileService getFileService() {
		return this.fileService;
	}

	public void setFileService(FileService fileService) {
		this.fileService = fileService;
	}

	public ODocument getDocument() {
		return this.document;
	}

	public void setDocument(ODocument document) {
		this.document = document;
	}

	public String getPropertyIds() {
		return this.propertyIds;
	}

	public void setPropertyIds(String propertyIds) {
		this.propertyIds = propertyIds;
	}

	public String getNbyj() {
		return this.nbyj;
	}

	public void setNbyj(String nbyj) {
		this.nbyj = nbyj;
	}

	public String getLdps() {
		return this.ldps;
	}

	public void setLdps(String ldps) {
		this.ldps = ldps;
	}

	public String getBlqk() {
		return this.blqk;
	}

	public void setBlqk(String blqk) {
		this.blqk = blqk;
	}

	public String getDcdb() {
		return this.dcdb;
	}

	public void setDcdb(String dcdb) {
		this.dcdb = dcdb;
	}

	public String getDocId() {
		return this.docId;
	}

	public void setDocId(String docId) {
		this.docId = docId;
	}

	public int getNodeId() {
		return this.nodeId;
	}

	public void setNodeId(int nodeId) {
		this.nodeId = nodeId;
	}

	public String getMessage() {
		return this.message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getSupervisionTag() {
		return this.supervisionTag;
	}

	public void setSupervisionTag(String supervisionTag) {
		this.supervisionTag = supervisionTag;
	}

	public String getExecutors() {
		return this.executors;
	}

	public void setExecutors(String executors) {
		this.executors = executors;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getFlowId() {
		return this.flowId;
	}

	public void setFlowId(String flowId) {
		this.flowId = flowId;
	}

	public String[] getUserIds() {
		return this.userIds;
	}

	public void setUserIds(String[] userIds) {
		this.userIds = userIds;
	}

	public String getContentId() {
		return this.contentId;
	}

	public void setContentId(String contentId) {
		this.contentId = contentId;
	}
}

/*
 * Location: /Volumes/work/oa/WEB-INF/classes/ Qualified Name:
 * andriod.action.doc.ArdDocAction JD-Core Version: 0.6.0
 */